#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <ctime>

void bubbleSort(std::vector<int> &arr) {
    for (int i = 0; i < arr.size() - 1; i++) {
        for (int j = 0; j < arr.size() - i - 1; j++) {
            if (arr[j] > arr[j + 1]) {
                std::swap(arr[j], arr[j + 1]);
            }
        }
    }
}

int main() {
    std::vector<std::string> files = {"m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"};
    for (const auto &file : files) {
        std::ifstream f(file);
        std::vector<int> nums;
        int num;
        while (f >> num) {
            nums.push_back(num);
        }
        f.close();
        std::clock_t start_time = std::clock();
        bubbleSort(nums);
        std::clock_t end_time = std::clock();
        int duration = (end_time - start_time) * 1000 / CLOCKS_PER_SEC;
        std::string filename = file.substr(0, file.find('.'));
        std::cout << filename << " duration " << duration << " milliseconds" << std::endl;
    }
    return 0;
}
